<%@page import="helpers.LanguageHelper"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="java.util.TreeMap"%>
<%@page import="entities.User"%>
<%
User user = (User) request.getAttribute("user");
TreeMap check = (TreeMap) request.getAttribute("check");
String success = (String) request.getAttribute("success");

//Set content for seo
String nameServer = UrlHelper.getDomainServer(request);
String title = LanguageHelper.getString("profile_edit_title") + " " + user.getUsername() + " - " + nameServer;
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/layouts/header.jsp">
	<jsp:param name="title" value="<%=title %>" />
    <jsp:param name="ogtitle" value="<%=title %>" />
</jsp:include>

            <div id="mainContent" class="left">
                <div id="editProfilePage">
                	<h3 class="title"><%=LanguageHelper.getString("profile_edit_page") %></h3>
                	<% if (success != null) { %>
                	<div class="messageBox-success"><%=success %></div>
                	<% } %>
                    <div class="editProfile clearafter">
                    	<form method="post" class="formStyle">
                            <div class="left authorAvatar">
                                <a href="/profile/change-avatar"><%=LanguageHelper.getString("avatar_page") %></a>                            
                            </div>
                            <div class="clearbreak"></div>
                            <div class="left <%=check.get("name") != null ? "error" : ""%>">
                                <label><%=LanguageHelper.getString("profile_name_label") %> :</label> <input type="text" name="name" value="<%=user.getName() %>"  />
                                <% if (check.get("name") != null) { %>
                                <p class="errorMessage"><%=check.get("name") %></p>
                                <% } %>
                            </div>
                            <div class="right <%=check.get("gender") != null ? "error" : ""%>">
                                <label><%=LanguageHelper.getString("profile_gender_label") %> :</label> 
                                <select name="gender">
                                	<option value="0"><%=LanguageHelper.getString("male") %></option>
                                	<option value="1"><%=LanguageHelper.getString("female") %></option>
                                </select>
                                <% if (check.get("gender") != null) { %>
                                <p class="errorMessage"><%=check.get("gender") %></p>
                                <% } %>
                            </div>
                            <div class="clearbreak"></div>
                            <div class="left <%=check.get("email") != null ? "error" : ""%>">
                                <label><%=LanguageHelper.getString("profile_email_label") %> :</label> <input type="text" name="email" value="<%=user.getUsername()%>" readonly="readonly"/>
                                <% if (check.get("email") != null) { %>
                                <p class="errorMessage"><%=check.get("email") %></p>
                                <% } %>
                            </div>
                            <div class="right <%=check.get("website") != null ? "error" : ""%>">
                                <label><%=LanguageHelper.getString("profile_website_label") %> :</label> <input type="text" name="website" value="<%=user.getWebsite() %>" />
                                <% if (check.get("website") != null) { %>
                                <p class="errorMessage"><%=check.get("website") %></p>
                                <% } %>
                            </div>
                            <div class="clearbreak"></div>
                            <div class="<%=check.get("aboutme") != null ? "error" : ""%>">
                                <label><%=LanguageHelper.getString("profile_about_label") %> :</label>
                                <textarea name="aboutme"><%=user.getAboutme() %></textarea>
                                <% if (check.get("aboutme") != null) { %>
                                <p class="errorMessage"><%=check.get("aboutme") %></p>
                                <% } %>
                            </div>
                            <button type="submit"><%=LanguageHelper.getString("change_profile") %></button>
                        </form>
                    </div>                    
                </div>
            </div>
            
            <jsp:include page="/elements/right.jsp" />
            
            <div class="clearbreak"></div>
<jsp:include page="/layouts/footer.jsp" />